<?php
class NeoSession {
    private $ID;
	private $Type;
	private $Licenses = array();
	static private $Session=false;
	static private function getInstance(){
		if (!isset($_SESSION['session'])){
			self::$Session =new NeoSession();
			self::$Session->ID = -1;
			self::$Session->Type = 0 ;
			$_SESSION['session'] = serialize(self::$Session);
		}else{
			if(self::$Session instanceof Session) return;
			self::$Session = unserialize($_SESSION['session']);
		}
	}
	static function login($email_address,$password){
		if($password == "")
                    return false;
		self::getInstance();
		$id = FunctionData::readAccountId($email_address);
		if($id>-1){
			$reg_data = FunctionGameLoto::readAccountRegisterInfo($email_address);
			if($reg_data->getPasswordHash() == UtilHash::sha256( $password ) ){
				self::$Session ->ID = $id;
				self::$Session ->Type = 1 ;
			}else{
			}
		}else{
		}
		$_SESSION['session'] = serialize(self::$Session);
		if(self::$Session->ID > -1){
			return true;
		}
		return false;
	}
        static function getIdentify(){
		self::getInstance();
		return FunctionData::getIdentifyFromId(self::$Session ->ID);
	}
        static function isLogin(){
		self::getInstance();
		if(self::$Session->ID>-1){
			return true;
		}
		return false;
	}
	static function getID(){
		return self::$Session ->ID;
	}
}
?>